R tip of the day

GGtheme

George James

2024-11-07

An intro to ggthemeassist

GGThemeAssist function in R

-This package works as an add in in R studio

-This package in R allows us to go more into depth in Data visulization. Instead of just adding a color of a clean_theme.

-This package is very useful for people who don’t want to code every detail of the ggplot. Especally the changes that are less obvious.

before ggtheme

ggplot(
  data = penguins,
  mapping = aes(x = flipper_length_mm, y = body_mass_g)
) +
  geom_point()

plot results

After ggtheme

ggplot(
  data = penguins,
  mapping = aes(x = flipper_length_mm, y = body_mass_g)
) +
  geom_point() + theme(plot.subtitle = element_text(family = "mono",
    size = 8, face = "italic"), axis.line = element_line(linetype = "twodash"),
    panel.grid.major = element_line(linetype = "blank"),
    panel.grid.minor = element_line(linetype = "blank"),
    axis.title = element_text(family = "mono"),
    axis.text = element_text(size = 9), axis.text.y = element_text(size = 8),
    plot.title = element_text(family = "mono"),
    panel.background = element_rect(fill = "white"),
    plot.background = element_rect(fill = "azure",
        colour = NA)) +labs(title = "Happy Feet", x = "Flipper Length(mm)",
    y = "Body Mass(g)", subtitle = "Flipper length and body mass of penguins")

lets see another example and a walk through:

ggtheme: